package com.wushijia.designpatterns.observer.bug;

import java.util.Date;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class BugLotteryService {

  private final MinibusTargetService minibusTargetService = new MinibusTargetService();

  public LotteryResult doDraw(String uId) {                       // 摇号
    String lottery = minibusTargetService.lottery(uId);           // 发送通知短信
    log.info("给用户 {} 发送通知(短信)：{}", uId, lottery);          // 发送MQ消息
    log.info("记录用户 {} 摇号结果(MQ)：{}", uId, lottery);          // 结果
    return new LotteryResult(uId, lottery, new Date());
  }
}
